package com.yyplatform.frontend.infra.utils;

import org.apache.commons.lang3.StringUtils;

/**
 * Created on 2024-10-18
 */
public class NumberUtils {

    public static int toInt(String str, int defV) {
        if (StringUtils.isEmpty(str)) {
            return defV;
        }

        if (!StringUtils.isNumeric(str)) {
            return defV;
        }

        try {
            return Integer.parseInt(str);
        } catch (Exception ex) {
            return defV;
        }

    }
}
